package com.example.rabbit.controller;


import com.example.common.dto.BaseReturnDto;
import com.example.rabbit.entity.RabbitDO;
import com.example.rabbit.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tc
 * @since 2022-10-29
 */
@RestController
public class RabbitController {
    @Autowired
    RabbitService rabbitService;
    @GetMapping("/rabbit")
    public BaseReturnDto<List<Map<String, Object>>> list(){
        List<Map<String, Object>> list =rabbitService.getCandR();
        return BaseReturnDto.success().msg("查询成功").data(list);
    }
    /*
    *添加
    * */
    @GetMapping("/rabbit/add")
    public BaseReturnDto<RabbitDO> add(@RequestParam("varieties")String varieties,
                                       @RequestParam("sex")String sex,
                                       @RequestParam("cid")String cid,
                                       @RequestParam("saleTime")String saleTime,
                                       @RequestParam(value = "name",required = false,defaultValue = "")String name,
                                       @RequestParam(value = "color",required = false) String color,
                                       @RequestParam("statu")Integer statu
                                       ){
        return rabbitService.addRabbit(varieties, name, sex, saleTime, cid, color, statu);
    }
}

